﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test.PLCController
{
    public class PLCBuilder : IPLCBuilder
    {
        private PLCBaseInfo  pLCBaseInfo;
        private PLCConnectionInfo pLCConnectionInfo;
        private IPLC pLC;

        public IPLCBuilder BuildPLCBaseInfo(Action<PLCBaseInfo> buildPLCBaseInfoDelegate)
        {
            pLCBaseInfo = new PLCBaseInfo();
            buildPLCBaseInfoDelegate.Invoke(pLCBaseInfo);
            return this;
        }

        public IPLCBuilder BuildPLCConctionInfo(Action<PLCConnectionInfo> buildPLCConnectionInfoDelegate)
        {
            pLCConnectionInfo = new PLCConnectionInfo();
            buildPLCConnectionInfoDelegate.Invoke(this.pLCConnectionInfo);
            return this;
        }

        public IPLC Builder()
        {
            pLC = PLCFactory.CreatePLC(pLCBaseInfo, pLCConnectionInfo);
            return pLC;

        }
    }
}
